/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package idv.cloudee.proxy2.impl.getpost;

/**
 *
 * @author Cloudee
 */
public class DefaultGETPOSTModifierFactory implements GETPOSTModifierFactory {

    private Class<? extends GETPOSTModifier> cls;
    private boolean enable = true;
    private static final GETPOSTModifier dummyImpl = new GETPOSTModifierDummyImpl();

    public DefaultGETPOSTModifierFactory(Class<? extends GETPOSTModifier> cls) {
        this.cls = cls;
    }

    public boolean isEnable() {
        return enable;
    }

    public void setEnable(boolean enable) {
        this.enable = enable;
    }

    public GETPOSTModifier getGETPOSTModifier() {
        try {
            if (enable) {
                return cls.newInstance();
            } else {
                return dummyImpl;
            }
        } catch (Exception ex) {
            throw new RuntimeException(ex);
        }
    }
}
